import Cookies from 'js-cookie'

const TokenKey = 'PorkingLot-Admin-Token'
const UserKey = 'PorkingLot-Admin-User-Info'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  removeUser()
  return Cookies.remove(TokenKey)
}

export function getUser() {
  const user = Cookies.get(UserKey)
  if (user) { return JSON.parse(user) }
  return {}
}

export function setUser(user) {
  return Cookies.set(UserKey, user)
}

export function removeUser() {
  return Cookies.remove(UserKey)
}
